<template>
	<view class="team">
		<view class="commonLi0">
			<view style="width: 600upx;" class="">
				<view class="fs22 C333">
					开启自选
				</view>
				<view style="width: 600upx;" class="fs18 C999">
					开启自选后，您的小店里只显示您选择的产品
				</view>
			</view>
			<view style="width: 72pux;height: 40upx;transform: scale(0.6);" class="fs27">
				<switch color="#4cd964" :checked="check1" @change="switch1Change" />
			</view>
		</view>
		<!-- <view class="commonLi0">
			<view style="width: 600upx;" class="">
				<view class="fs22 C333">
					开启分类
				</view>
				<view style="width: 600upx;" class="fs18 C999">
					如果您选择的商品较多，建议您开启与总店同步分类
				</view>
			</view>
			<view style="width: 72pux;height: 40upx;transform: scale(0.6);" class="fs27">
				<switch :checked="check2" color="#4cd964" @change="switch2Change" />
			</view>
		</view> -->
		<view class="commonLi0">
			<view style="width: 500upx;" class="fs22 C333">
				选择商品		
			</view>
			<view style="color: #ff4300;" class="fs22">
				<navigator url="selectProduct">					
					+添加商品	
				</navigator>
			</view>
		</view>
		<view v-for="(item,index) in goodsList" :key="index" class="commonLi">
			<view style="width: 160upx;height: 140upx;" class="">
				<image style="width: 140upx;height: 140upx;" :src="item.goods_image_url" mode=""></image>
			</view>
			<view style="display: flex;justify-content: space-between;flex-direction: column;width: 520upx;"  class="">
				<view style="width: 370upx;min-height: 80upx;" class="fs20 C333 twoline lh40">
					{{item.goods_name}}
				</view>
				<view style="display: flex;justify-content: space-between;" class="">
					<view class="fs18 Cf00">
						￥{{item.goods_price}}
					</view>
					<view @click="del(item.goods_id)" style="border: 1upx solid #999;padding: 3upx 20upx;border-radius: 30upx;height: 36upx;line-height: 36upx;" class="fs20 C999">
						删除
					</view>
				</view>				
			</view>
		</view>
		
		<!-- <view @click="ok()" class="sunmitBtn Cfff fs18">
			保存设置
		</view> -->
		
		<view style="margin-bottom: 200upx;display: none;" class="fs18 tac lh100">
			暂无更多数据
		</view>
		 <view style="display: none;" class="bottom">
			<view :class="[(active2flag == index)?'active2':'']" @click="tab2(index,item.toUrl)" v-for="(item,index) in bottomBtn" :key="index">		 		
				<image :src="active2flag == index ? item.img2 :item.img1" mode=""></image>
				<view :class="[(active2flag == index) ? 'active2':'']">
					{{item.name}}
				</view>
			</view>
		 </view>		
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				aa:0,
				bb:0,
				check1:false,
				check2:false,
				goodsList:[],
				lis:[0,1,2,3,4],
				active1:0,
				active2flag:2,
				bottomBtn:[
					{"name":"首页","img1":"../../static/images/home_bottom11.png","img2":"../../static/images/home_bottom12.png","toUrl":"../home/index"},
					{"name":"分类","img1":"../../static/images/home_bottom21.png","img2":"../../static/images/home_bottom22.png","toUrl":"../sort/sortPage"},
					{"name":"分销","img1":"../../static/images/home_bottom31.png","img2":"../../static/images/home_bottom32.png","toUrl":"../distribution/list"},
					{"name":"购物车","img1":"../../static/images/home_bottom41.png","img2":"../../static/images/home_bottom42.png","toUrl":"../car/shopCar"},
					{"name":"会员中心","img1":"../../static/images/home_bottom51.png","img2":"../../static/images/home_bottom52.png","toUrl":"/pages/home/Personal_Center"}
				]
			}
		},
		onShow() {
			this.getLis()
		},
		onLoad() {
			this.getLis()
		},
		methods: {
			// ok(){
			// 	uni.showToast({
			// 		title:"设置成功",
			// 		success() {
			// 			setTimeout(()=>{
			// 			uni.navigateBack({
			// 				delta:1
			// 			})
			// 			},1000)
			// 		}
			// 	})
			// },
			del(goods_id){
				console.log()
				uni.showModal({
				    title: '提示',
					content:'是否删除该商品？',
				    success: (res)=> {
				        if (res.confirm) {
				            console.log('用户点击确定');
							this.$util.request({
								url: '/mobile/index.php?act=distribution&op=delShopGood',
								method: 'get',
								data: {
									"goodId":goods_id
								},
							}).then((res2)=> {
								if(res2.error_code == 0){
									uni.showToast({
										title:res2.datas
									})
									this.getLis()
								}
							})
				        } else if (res.cancel) {
				            console.log('用户点击取消');							
				        }
				    }
				});
				
			},
			switch1Change: function (e) {
				this.check1=e.target.value
				this.aa=this.check1 ? 1 :0
				this.bb=this.check2 ? 1 :0
				
				this.$util.request({
					url: '/mobile/index.php?act=distribution&op=submitShopSelectInfo',
					method: 'post',
					data: {
						"selectgoods":this.aa,
						"selectcategory":this.bb
					},
				}).then((res)=> {
					if(res.error_code==0){
						uni.showToast({
							title:this.check1 ?'开启成功':'关闭成功',
							icon:"none"
						})
					}else{
						uni.showToast({
							title:res.message,
							icon:"none"
						})
					}
				})
			},
			switch2Change: function (e) {
				console.log('switch2 发生 change 事件，携带值为', e.target.value)
				this.check2=e.target.value
				this.aa=this.check1 ? 1 :0
				this.bb=this.check2 ? 1 :0
		
				this.$util.request({
					url: '/mobile/index.php?act=distribution&op=submitShopSelectInfo',
					method: 'post',
					data: {
						"selectgoods":this.aa,
						"selectcategory":this.bb
					},
				}).then((res)=> {
				
				})
			},
			getLis(){
				this.$util.request({
					url: '/mobile/index.php?act=distribution&op=getShopSelectInfo',
					method: 'get',
					data: {},
				}).then((res)=> {
					this.check1=res.datas.selectSet.selectgoods ? true : false
					this.check2=res.datas.selectSet.selectcategory ? true : false
					this.goodsList=res.datas.goodsList
					// this.lis=res.datas.list
				})
			},
			tab2(index,url){
				this.active2flag=index				
				uni.switchTab({
					url:url
				})
			}			
		}
	}
</script>

<style>	
	.status_bar {
	    height: var(--status-bar-height);  
	    width: 100%;  
	    background-color: #fca2a2;
	}  
	.top_view {  
	    height: var(--status-bar-height);  
	    width: 100%;  
	    position: fixed;  
	    background-color: #fca2a2;  
	    top: 0;  
	    z-index: 999;  
	}
	.lh20{
		line-height: 20upx;
		height: 20upx;
	}
	.lh25{
		line-height: 25upx;
	}
	.lh30{
		line-height: 30upx;
	}
	.lh35{
		line-height: 35upx;
	}
	.lh40{
		line-height: 40upx;
	}
	.lh45{
		line-height: 45upx;
	}
	.lh50{
		line-height: 50upx;
	}
	.lh100{
		line-height: 100upx;
	}
	.C000{
		color: #000000;
	}
	.Ce13d97{
		color: #ff4300;
	}
	.Cfe0000{
		color: #ff4300;
	}
	.Cc06{
		color: #ff4300;
	}
	.mt55mb30{
		margin-top: 55upx;
		margin-bottom: 30upx;
	}
	.Cfff{
		color: #FFFFFF;
	}

	.flex{		
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-content: space-between;
	}
	.paddingL20{
		padding-left: 20upx;
	}
	.C999{
		color:#999 ;
	}
	.Cff0101{
		color:#ff0101 ;
	}
	.Cc00251{
		color: #c00251;
	}
	.strick{
		text-decoration: line-through;
	}
	.Cfe0000{
		color: #ff4300;
	}
	.line1{
		width: 430upx;
	}
	.hide{
		display: none;
	}
	.marginB20{
		margin-bottom: 20upx;
	}
	
	.twoline{
	   overflow : hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
	.pl20{
		padding-left: 20upx;
	}
	.positionT{
		position: relative;
		top: 50upx;
	}
	.paddingB15{
		padding-bottom: 15upx;
	}
	.borderB{
		border-bottom: 1px solid #f4f4f6;
	}
	.borderT{
		border-top: 1px solid #f4f4f6;
	}
	.gl{
		position: absolute;
		right: 30upx;
	}
	.pr30{
		padding-right: 30upx;
	}
	.C333{
		color: #333333;
	}
	.C666{
		color: #666666;
	}
	.Cf00{
		color: #ff0000;
	}
	
	.bold{
		font-weight: bold;
	}
	.C1d1d1d{
		color:#1d1d1d ;
	}
	.fl{
		float: left;
	}
	.fr{
		float: right;
	}
	.tac{
		text-align: center;
	}
	.Ce5258e{
		color: #e5258e;
	}
	.Cccc{
		color: #CCCCCC;
	}
	uni-page-body {
		
	}		
	.fs30{
		/* font-size: 30upx */
		font-size: 45upx
	}
	.fs26{
		font-size:39upx
		/* font-size: 26upx */
	}
	.fs12{
		font-size: 18upx
		/* font-size: 12upx */
	}
	.fs16{
		font-size: 24upx
		/* font-size: 16upx */
	}
	.fs14{
		font-size: 21upx
		/* font-size: 14upx */
	}
	.fs15{
		font-size: 22.5upx
		/* font-size: 15upx */
	}
	.fs27{
		font-size: 40.5upx
		/* font-size: 27upx */
	}
	.fs18{
		font-size: 27upx
		/* font-size: 18upx */
	}
	.fs28{
		font-size: 42upx
		/* font-size: 28upx */
	}
	.fs10{
		font-size: 15upx
		/* font-size: 10upx */
	}
	.fs30{
		font-size: 45upx
		/* font-size: 28upx */
	}
	.fs24{
		font-size: 36upx
		/* font-size: 24upx */
	}
	.fs20{
		font-size:30upx
		/* font-size: 20upx */
	}
	.fs22{
		font-size:33upx
		/* font-size: 22upx */
	}
	.fs21{
		font-size: 31.5upx
		/* font-size: 21upx */
	}
	
	.bottom{
		box-sizing: border-box;
		padding: 0 10upx;
		background-color: #FFFFFF;
		position: fixed;
		z-index: 99999999999;
		left: 0;
		bottom: 0;
		height: 98upx;
		width: 100%;
		box-shadow: 0upx -1upx 10upx rgba(0,0,0,0.8);
		display: flex;
		flex-direction: row;
		justify-content: space-around;
	}
	.bottom view{
		font-size: 27upx;
		color: #666;
		text-align: center;
	}
	.bottom view.active2{
		color: #ff4300;
	}
	.bottom image{
		position: relative;
		top: 15upx;
		width: 33upx;
		height: 33upx;
	}
	.title2{
		margin-top: 76upx;
		margin-bottom: 0upx;
		height: 35px;
		padding-left: 20upx
	}
	.oneLine{
		text-overflow: ellipsis;
		overflow: hidden;
		white-space: nowrap;
	}
	.Ce5007e{
		color: #e5007e;
	}
	.team{
		background-color: #F4F4F4;		
	}
	.active1{
		color: #ff4300;
	}
	.commonLi{		
		margin-top:25upx;
		padding:20upx 30upx ;
		box-sizing: border-box;
		background-color: #FFFFFF;
		display: flex;	
		height: 180upx;
	}
	.commonLi0{
		margin-top:25upx;
		padding:20upx 30upx ;
		box-sizing: border-box;
		background-color: #FFFFFF;
		display: flex;	
		justify-content: space-between;
		align-items: center;
	}
	.sunmitBtn{
		background: linear-gradient(to right,#ff4300,#db1060,#c10451);
		width: 668upx;
		height: 72upx;
		line-height: 72upx;
		margin: 283upx auto 100upx;
		text-align: center;
	}
</style>
